<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:desk="http://desk.com"
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <link rel="stylesheet" type="text/css" href="resources/params.css"/>
    </h:head>
    <h:body>
        <desk:header/>
        <h:form styleClass="regForm">
            <h:panelGrid columns="3" columnClasses="regInputInfo,regInput,regErrors">
                    <h:outputText value="First name"/>
                    <p:inputText value="#{rb.firstName}" required="true" id="fname" 
                                 requiredMessage="Please enter your name" 
                                 validatorMessage="Name must consist of letters only">
                        <f:validateRegex pattern="[A-Za-zА-Яа-я]+"/>
                    </p:inputText>
                    <p:message for="fname"/>

                    <h:outputText value="Last name"/>
                    <p:inputText value="#{rb.lastName}" required="true" id="lname" 
                                 requiredMessage="Please enter your last name" 
                                 validatorMessage="Name must consist of letters only">
                        <f:validateRegex pattern="[A-Za-zА-Яа-я]+"/>
                    </p:inputText>
                    <p:message for="lname"/>

                    <h:outputText value="e-mail (used for notifications)"/>
                    <p:inputText value="#{rb.email}" required="true" id="email"
                                 requiredMessage="Please enter your email" 
                                 validatorMessage="Not a valid email">
                        <f:validateRegex pattern="\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b"/>
                    </p:inputText>
                    <p:message for="email"/>

                    <h:outputText value="Login"/>
                    <p:inputText value="#{rb.login}" required="true" id="login" 
                                 requiredMessage="Please enter your login"/>
                    <p:message for="login"/>

                    <h:outputText value="Password"/>
                    <p:password value="#{rb.password}" required="true" id="password" 
                                 requiredMessage="Please enter your password" 
                                 validatorMessage="Password should be at least 3 characters length"
                                 feedback="false"
                                 minLength="3">
                        <f:validateLength minimum="3"/>
                    </p:password>
                    <p:message for="password"/>

                    <h:outputText/>
                    <h:selectOneRadio value="#{rb.roleID}" required="true" id="role"
                                      requiredMessage="Select your role">
                        <f:selectItems value="#{rb.roles}"/>
                    </h:selectOneRadio>
                    <p:message for="role"/>

                    <h:outputText/>
                    <h:commandButton value="Sign up"  action="#{rb.register}" styleClass="regInput"/>

                </h:panelGrid>
            <p:messages globalOnly="true"/>
        </h:form>
    </h:body>
</html>
